<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>百媚后花园</title>
    <script src="../base/js/jquery-1.10.2.js"></script>
    <script src="../base/js/XT.js"></script>
    <link rel="stylesheet" href="../base/css/weui.css">
    <style>
        body {
            background-color: #fbf9fe;
        }
        .page_title {
            text-align: center;
            font-size: 34px;
            color: #3cc51f;
            font-weight: 400;
            margin: 20px 15% 0;
        }
        .weui_dialog_alert{
            display: none;
        }
        .m{
            margin-top: 40px;
        }
    </style>
</head>
<body ontouchstart="">
    <h1 class="page_title">Back Garden</h1>

    <section class="m">
        <div class="weui_btn_area">
            <a href="js-garden.html" class="weui_btn weui_btn_primary">Javascript Bridge</a>
            <a href="scheme-garden.html" class="weui_btn weui_btn_primary">Scheme</a>
            <a href="#" id="getSign" class="weui_btn weui_btn_primary">获取签名信息(GET)</a>
            <a href="#" id="getSign2" class="weui_btn weui_btn_primary">获取签名信息(POST)</a>
            <a href="../mywallet/index.html" class="weui_btn weui_btn_primary">我的钱包</a>
            <a href="../level/index.html" class="weui_btn weui_btn_primary">我的等级</a> 
            <a href="###" class="weui_btn weui_btn_primary" id="qchc">清除缓存</a>
            <a href="../open/index.html?appKey=96e92360330f4990&userId=5313&goodsId=212&goodsName=testGoods&time=1510733461390&money=100&ext=demo&gameOrderId=2017111610100223&sign=b9e28d34566c5a5d276fe03aee9a2d3" class="weui_btn weui_btn_primary">h5游戏充值</a>
 
            <a class="weui_btn weui_btn_primary" href="https://h5-t.chinaqljf.com/medal/index.html?userId=5339">勋章</a>
 
            <a href="../open/alipay.html" class="weui_btn weui_btn_primary">alipay</a>
            <a href="../active/sgShop_1207.html" class="weui_btn weui_btn_primary">闪购商城活动1207</a>
 
            <!--<a href="../active/sgShop.html" class="weui_btn weui_btn_primary">闪购双十一</a>-->
            <!-- <a href="static-setting.html" class="weui_btn weui_btn_primary">静态图片页面生成</a>
					 <a href="../shijie/index.html?shareType=activity&shareId=1" class="weui_btn weui_btn_primary">世姐报名</a>
					 <a href="../nverguo/index.html?shareType=activity&shareId=2" class="weui_btn weui_btn_primary">女儿国</a>
					 <a href="../zhainan/index.html?shareType=activity&shareId=3" class="weui_btn weui_btn_primary">宅男评审</a>
					 <a href="../vote/index.html?shareType=activity&shareId=3" class="weui_btn weui_btn_primary">投票</a>
					 <a href="../ranking/index.html?shareType=activity&shareId=3" class="weui_btn weui_btn_primary">排名</a>
					 <a href="../newnverguo/text.html?shareType=activity&shareId=2&rank=true" class="weui_btn weui_btn_primary">视频聚合</a>
					 <a href="../task_reward/index.html" class="weui_btn weui_btn_primary">做任务，赢奖励</a>
					 <a href="../Indiana_ranking/index.html" class="weui_btn weui_btn_primary">夺宝排行榜</a>
					 <a href="../rank_top30/index.html?extCode=rank_top30" class="weui_btn weui_btn_primary">评委投票</a>
					 <a href="../patron_saint_1/index.html?extCode=patron_saint" class="weui_btn weui_btn_primary">守护神</a>
					 <a href="../forback/text.html" class="weui_btn weui_btn_primary">总结赛回顾</a>
					 <a href="../bad_song/index.html" class="weui_btn weui_btn_primary">毁歌大赛</a>
					 <a href="../peak_21/index.html" class="weui_btn weui_btn_primary">巅峰21点</a> -->
        </div>
    </section>

    <div class="weui_dialog_alert">
        <div class="weui_mask"></div>
        <div class="weui_dialog">
            <div class="weui_dialog_hd"><strong class="weui_dialog_title">弹窗标题</strong></div>
            <div class="weui_dialog_bd">弹窗内容，告知当前页面信息等</div>
            <div class="weui_dialog_ft">
                <a href="#" class="weui_btn_dialog primary">确定</a>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        var urlEncode = function (param, key, encode) {
          if(param==null) return '';
          var paramStr = '';
          var t = typeof (param);
          if (t == 'string' || t == 'number' || t == 'boolean') {
            paramStr += '&' + key + '=' + ((encode==null||encode) ? encodeURIComponent(param) : param);
          } else {
            for (var i in param) {
              var k = key == null ? i : key + (param instanceof Array ? '[' + i + ']' : '.' + i);
              paramStr += urlEncode(param[i], k, encode);
            }
          }
          return paramStr;
        };

        function getConfig(obj, cb){
            XT.jsonp({
                url: '/share/share-config',
                data: obj,
                success: function(data) {
                    cb && cb(data);
                },
                validMsg: function(msg) {
                    alert(msg);
                }
            })
        }

        var $links = $('.weui_btn_area');
        function addLink(data){
            var $a = $('<a href="'+data.value+'" class="weui_btn weui_btn_primary">'+data.label+'</a>');
            $links.append($a);
            return;
        }
        //后花园地址配置
        getConfig({shareKey: 'garden_link1'}, function(data){
            data.label = '后花园地址1';
            addLink(data);
        });

        getConfig({shareKey: 'garden_link2'}, function(data){
            data.label = '后花园地址2';
            addLink(data);
        });


        var $alert = $('.weui_dialog_alert');
        $alert.on('click', '', function(){
            $alert.hide();
        });
        function showAlert(title, content){
            $alert.show();
            $alert.find('.weui_dialog_title').html(title);
            $alert.find('.weui_dialog_bd').html(content);
        }
        $('#getSign').click(function(){
            XT.bridge.call('getUserInfo', {}, function(res) {
                var info = JSON.parse(res);
                XT.user.uid = info.id;
                XT.sign('GET', {userId: XT.user.uid}, function(data){
                    alert(JSON.stringify(data));
                    showAlert('提示', '签名：'+data.sign);
                    var req = $.extend({userId: XT.user.uid, sign:data.sign}, data.parameters);
                    XT.jsonp({
                        url: '/user/profile',
                        data: req,
                        jsonpCallback: 'profile',
                        success: function (data) {
                            alert(data.nickname);
                            showAlert('提示', '昵称：'+data.nickname);
                        }
                    })
                });
            });
            return false;
        });

        $('#qchc').click(function(){
            XT.tools.removeStorage('all');
        });
        
        $('#getSign2').click(function(){
            // var info = {
            //   "activityId": 0,
            //   "area": "string",
            //   "birthday": "string",
            //   "chest": "string",
            //   "height": "string",
            //   "hipline": "string",
            //   "id": 0,
            //   "manifesto": "string",
            //   "mobile": "string",
            //   "realName": "string",
            //   "userId": 0,
            //   "waistline": "string",
            //   "weight": "string"
            // };
            // XT.sign('POST', info, function(data){
            //     alert(JSON.stringify(data));
            //     showAlert('提示', '签名：'+data.sign);
            //     info.sign = data.sign;
            //     var req = $.extend(info, data.parameters);
            //     XT.post({
            //         url: '/activity-signup/miss-world',
            //         data: req,
            //         jsonpCallback: 'mis-world',
            //         success: function (data) {
            //             showAlert('提示', '报名成功！');
            //         }
            //     })
            // });
            XT.bridge.call('getUserInfo', {}, function(res) {            
                var user = JSON.parse(res);
                var info = {
                    openId: user.id,
                    aid:XT.search.anchorId,
                    nickName:user.nickname,
                    sex:Number(user.gender!='MALE'),
                    icon:user.avatarUrl
                }
                alert(JSON.stringify(info));
                XT.sign('POST', info, function(data){
                    var _tmp = $.extend({sign:data.sign}, data.parameters);
                    info.platformToken = urlEncode(_tmp).substr(1);
                    info.callback = 'check';
                    // var req = $.extend(info, data.parameters);
                    alert(JSON.stringify(info));
                    XT.post({
                        url: 'http://116.62.103.157:8080/api-bdx/token/check',
                        data: info,
                        jsonpCallback: 'check',
                        success: function (user) {
                            alert('创建游戏用户完成');                      
                        }
                    });
                });
            });
            return false;
        });

    </script>
</body>
</html>
